<template>
	<view>
		<view class="home-top" :style="'padding-top:'+titleHeight+'px'">云南省第一人民医院</view>
		<view class="home-image">
			<img class="img" src="../../static/tianqi-top.png" alt="">
			<view class="home-wz">
				<view class="wz">
					<view>
						<image style="width:40rpx;height: 40rpx;" :src="site[0].address_icon" mode=""></image>
						<text>{{site[0].name}}</text>
						<text>{{site[0].pname}}</text>
						<text>{{site[0].secondaryname}}</text>
					</view>
					<view class="tq">
						<image style="width:40rpx;height: 40rpx;" :src="site[0].tigan_icon" mode=""></image>
						<text>体感提问{{site[0].temp}}°</text>
					</view>
					<view class="zwx">
						<image style="width:40rpx;height: 40rpx;" :src="site[0].ziwxian_icon" mode=""></image>
						<text>紫外线强度{{site[0].realFeel}}w/m</text>
					</view>
					<view class="tq-b">
						<view>
							<text>11°</text>
							<image style="width:40rpx;height: 40rpx;" :src="site[0].icon" mode=""></image>
							<view>
								<text>温度{{site[0].humidity}}%</text>|<text>{{site[0].windDir}}{{site[0].windLevel}}</text>
								<view>{{site[0].tips}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<div class="hom-con">
			<div class="con-item" v-for="item,index in conlist" :key="index" @click="goym(index)">
				<image :src="item.image" mode=""></image>
				<view>{{item.title}}</view>
			</div>
		</div>
		<div class="con-itemb">
			<div v-for="item in conData">
				<div>{{item.title}}</div>
				<div>{{item.describe}}</div>
				<image :src="item.image" mode=""></image>
			</div>
		</div>
	</view>
</template>

<script>
	import {
		gethome,
		getfrontpage,
	} from "../../utils/api.js"
	export default {
		data() {
			return {
				titleHeight: 0,
				site: [],
				conlist: [],
				conData: [],
			};
		},
		methods: {
			// 安全胶囊
			getHeight() {
				let res = wx.getMenuButtonBoundingClientRect()
				// console.log(res, 17);
				this.titleHeight = res.top
			},
			//获取位置
			getdata() {
				let that = this
				uni.getLocation({
					type: 'gcj02',
					success(res) {
						console.log(res, 11111111111);
						gethome({
							longitude: res.longitude,
							latitude: res.latitude
						}).then(res => {
							console.log(res, 222222222);
							that.site = res.data.data
							console.log(that.site);
						})
					}
				})
			},
			// 请求导航栏
			getcon() {
				getfrontpage().then(res => {
					console.log(res, 81);
					this.conlist = res.data.data[0].vaccine
					this.conData = res.data.data[1].reserve
				})
			},
			// 跳转
			goym(index) {
				if (index == 0) {
					uni.navigateTo({
						url: "/pages/ymyy/ymyy"
					})
				}
			}
		},
		onLoad() {
			this.getHeight()
			this.getdata()
			this.getcon()
		}
	}
</script>

<style lang="scss">
	.home-top {
		color: #fff;
		font-weight: 600;
		line-height: 30px;
		margin-left: 40rpx;
		font-size: 17px;
	}

	.home-image {
		position: relative;
		width: 100%;
		height: 700rpx;

		.img {
			position: absolute;
			top: -120rpx;
			left: 0;
			width: 100%;
			height: 100%;
			z-index: -1;
		}

		.home-wz {
			width: 100%;
			color: #fff;
			padding: 0 20rpx;
		}

		.tq-b {
			width: 100%;
			height: 200rpx;
			margin-top: 100rpx;
			text-align: center;

			view {
				margin-top: 30rpx;
			}
		}
	}

	.hom-con {
		z-index: 1;
		width: 100%;
		height: 150rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;

		.con-item {
			flex: 1;
			text-align: center;

			>image {
				width: 50rpx;
				height: 50rpx;
			}
		}

	}

	.con-itemb {
		width: 100%;
		height: 260rpx;
		display: flex;

		>div {
			background-color: skyblue;
			position: relative;
			width: 45%;
			height: 100%;
			margin: auto;
			border-radius: 20rpx;

			>image {
				position: absolute;
				bottom: 0;
				right: 0;
				width: 200rpx;
				height: 150rpx;
			}
		}

	}
</style>
